<?

session_start();





function random_string($len=5, $str=''){

	for($i = 1; $i <= $len; $i++){

		$ord = rand(48, 122);
		
		$ord_exclude_array = array('48','49','53','57','105','108','111','112','113','115');
		
		if((($ord > 57) && ($ord < 97)) || (in_array($ord, $ord_exclude_array))){
			$str .= random_string(1); // The number is not good we generate another one
		}else{
			$str .= chr($ord);	                                       
		}
	
	}
	
	return $str;
	
}
                          

$text = random_string(5);

// create the hash for the random number and put it in the session
$_SESSION['image_random_value'] = md5($text);


// Set the content-type
header('Content-type: image/png');

// Create the image
$image = imagecreatetruecolor(70, 18);

// Create some colors
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, 100, 27, $white);

// Replace path by your own font path
$font = SITE_ROOT_PATH."/_lib/rockwell.ttf";

// Add the text
imagettftext($image, 14, 0, 3, 14, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagegif($image);
imagedestroy($image);



?>